#include <qwt_plot_curve.h>
#include "plotter.h"
#include "graph.h"

FirstPlot::FirstPlot( QWidget * parent ) : QwtPlot(parent) {
	setCanvasBackground( Qt::white );
	setAxisScale(QwtPlot::yLeft, 0, 400);
	enableAxis(QwtPlot::yLeft, false );
	
	//Graph *graph;
	//ColoredCurve *curve;

	/*curve = new ColoredCurve("Curve1");
	curve->setColor(Qt::red);
	curve->attach(this);
	graph = new Graph;
	graph->curve = curve;
	graphs.append( graph );

	curve = new ColoredCurve("Curve2");
	curve->setColor(Qt::green);
	curve->attach(this);
	graph = new Graph;
	graph->curve = curve;
	graphs.append( graph );*/
	
	viewWidth = 200;
	viewLeftBorder = 0;
	setAxisScale( QwtPlot::xBottom, viewLeftBorder, viewLeftBorder+viewWidth );

}
int FirstPlot::attachGraph( Graph * newGraph ) {
	int id = graphs.size();
	graphs.append( newGraph );
	newGraph->curve->attach(this);
	return id;
}

void FirstPlot::scrollPlot() {
	viewLeftBorder += 1;//dx;
	setAxisScale( QwtPlot::xBottom, viewLeftBorder, viewLeftBorder+viewWidth );
	replot();
}
